package fr.adfm.entity;

import java.util.Collection;
import java.util.Date;
import java.util.LinkedHashSet;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;

/**
 * An order.
 */
@Entity
public class Commande {
		
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	
	@OneToMany(cascade=CascadeType.ALL)
	@JoinColumn(name="Commande_ID")
	private Collection<LigneCommande> ligneCommandes = new LinkedHashSet<LigneCommande>();
	
	@ManyToOne
	@JoinColumn(name = "Client_Id")
	private Client client;
	
	@OneToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="Adresse_ID")
	private Adresse adresseDeFacturation;
	
	@OneToMany(cascade=CascadeType.ALL)
	@JoinColumn(name="Commande_ID")
	private Collection<Colis> colis = new LinkedHashSet<Colis>();
	
	public Adresse getAdresseDeFacturation() {
		return adresseDeFacturation;
	}

	public void setAdresseDeFacturation(Adresse adresseDeFacturation) {
		this.adresseDeFacturation = adresseDeFacturation;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	@Override
	public String toString() {
		return "Order [id=" + id + ", ligneCommandes=" + ligneCommandes
				+ ", dateHeureDerniereModification=" + dateHeureDerniereModification + "]";
	}

	public Collection<LigneCommande> getLigneCommandes() {
		return ligneCommandes;
	}

	public void setLigneCommandes(Collection<LigneCommande> ligneCommandes) {
		this.ligneCommandes = ligneCommandes;
	}

	public Date getDateHeureDerniereModification() {
		return dateHeureDerniereModification;
	}

	public void setDateHeureDerniereModification(Date dateHeureDerniereModification) {
		this.dateHeureDerniereModification = dateHeureDerniereModification;
	}
	
	

	public Collection<Colis> getColis() {
		return colis;
	}

	public void setColis(Collection<Colis> colis) {
		this.colis = colis;
	}



	private Date dateHeureDerniereModification;

	/**
	 * @return the id
	 */
	public Long getId() {
		return id;
	}

	
}
